public class Labyrinth {

    public static void main(String[] args) {
        Wall wa = new Wall();
        wa.test(4); // 调用 test 方法开始递归
        int res = wa.factorial(5);
        System.out.println("5的阶乘为：" + res);


        T t = new T();
        int n = -1;
        int fi = t.fibonacci(n);
        if(fi != -1){
            System.out.println("当n="+n+"对应的斐波那契数="+res);
        }
        System.out.println("fibonacci(5)=" + t.fibonacci(7));


        Labyrinth labyrinth = new Labyrinth();
        System.out.println("猴子吃桃子"+labyrinth.peach(2));

    }

    public int peach(int day){
        if(day == 10){
            return 1;
        }else if(day>=1  && day <= 9){
            return (peach(day+1)+1)*2;
        }else{
            System.out.println("day在1-10天");
            return -1;
        }
    }

}

// 首字母大写，符合 Java 命名规范
class Wall {
    public void test(int n) {
        if (n > 2) {
            test(n - 1); // 递归调用
        } else {
            System.out.println("n=" + n); // 基准情况输出
        }
    }

    public int factorial(int n) {
        if (n == 1) {
            return 1;
        } else {
            return n * factorial(n - 1);
        }
    }

}


class T{

    public int fibonacci(int n){
        if(n >= 1){
            if(n == 1|| n==2){
                return 1;
            }else{
                return fibonacci(n-1)+fibonacci(n-2);
            }

        }else{
            System.out.println("要求输入的n>=1的整数");
            return  -1;
        }
    }

}